package com.tju.resource.oauth.controller.tb;

import com.tju.resource.model.TbMatlStore;
import com.tju.resource.server.TbMatlStoreService;
import com.tju.resource.tool.result.Result;
import com.tju.resource.tool.tool.ClientParameters;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * 入库记录
 */
@RestController
public class TbMatlStoreController {
    private final static String prefix = "store/";
    @Autowired
    private TbMatlStoreService tbMatlStoreService;

    /**
     * 查询入库记录表
     */
    @PostMapping(prefix + "list")
    @PreAuthorize("hasAuthority('sys:tool:store:list')")
    public Result<Object> selectTbMatlStore(@RequestBody ClientParameters para) {
        return tbMatlStoreService.selectTbMatlStore(para);
    }

    /**
     * 新增入库记录表
     */
    @PostMapping(prefix + "add")
    @PreAuthorize("hasAuthority('sys:tool:store:add')")
    public Result<Object> insertTbMatlStore(@RequestBody TbMatlStore matlStore) {
        return tbMatlStoreService.insertTbMatlStore(matlStore);
    }

    /**
     * 删除入库记录表
     */
    @PostMapping(prefix + "delete")
    @PreAuthorize("hasAuthority('sys:tool:store:delete')")
    public Result<Object> selectTbMatlStore(@RequestBody TbMatlStore matlStore) {
        return tbMatlStoreService.deleteTbMatlStore(matlStore);
    }
}
